﻿namespace XKPlatform.Common
{
    public class WxPushHelper : ICorpMessageApi
    {/// <summary>
     /// 发送消息。
     /// 需要管理员对应用有使用权限，对收件人touser、toparty、totag有查看权限，否则本次调用失败。
     /// </summary>
     /// <param name="accessToken"></param>
     /// <returns></returns>
        public CommonResult SendMessage(string url, CorpSendBase data)
        {
            CommonResult result = new CommonResult();

            //string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}";
            //var url = string.Format(urlFormat, accessToken);
            //var postData = data.ToJson();

            ////数据不用加密发送
            //CorpSendResult sendResult = CorpJsonHelper<CorpSendResult>.ConvertJson(url, postData);
            //if (sendResult != null)
            //{
            //    result.Success = (sendResult.errcode == CorpReturnCode.请求成功);
            //    result.ErrorMessage = string.Format("invaliduser:{0},invalidparty:{1},invalidtag:{2}",
            //        sendResult.invaliduser, sendResult.invalidparty, sendResult.invalidtag);
            //}
            //ClientHelper client = new ClientHelper();
            //result= client.HttpPostAsync<CommonResult>(url, postData);

            return result;
        }

    }
}